{template common/header}
<!--{if !$_G['inajax']}-->
<div id="pt" class="wp"><a href="portal.php">$_G['setting']['bbname']</a> &rsaquo; {lang invite}</div>
<div id="ct" class="wp cl">
	<div class="mn">
		<div class="ch">
			<label class="wx">{lang invite}</label>
		</div>
		<div class="bm">
			<h1 class="mt">{lang invite_friend}$invitename</h1>
			<div class="usd usd2">
<!--{else}-->
		<div id="main_messaqge">
			<h3 class="flb">
				<em id="returnmessage4">{lang invite_friend}$invitename</em>
				<span>
					<!--{if $_G['inajax']}--><a href="javascript:;" class="flbc" onclick="hideWindow('invite')" title="{lang close}">{lang close}</a><!--{/if}-->
				</span>
			</h3>
			<div class="usd">
<!--{/if}-->
				<ul class="cl">
					<li>
						<p>{lang invite_orderby_name}</p>
						<p class="mtn"><input type="text" name="username" size="25" id="username" class="px" value="" autocomplete="off" /></p>
						<script type="text/javascript">
							var invitefs;
						</script>
					</li>
					<li>
						<p>{lang invite_orderby_friend}</p>
						<p class="mtn">
							<select class="ps" onchange="clearlist=1;getUser(1, this.value)">
								<option value="0">{lang invite_all_friend}</option>
								<!--{loop $friendgrouplist $groupid $group}-->
									<option value="$groupid">$group</option>
								<!--{/loop}-->
							</select>
						</p>
					</li>
				</ul>
				<div class="tbx">
					<span class="y">{lang invite_still_choose}(<strong id="remainNum">0</strong>){lang unit}</span>
					<span id="showUser_0" onclick="invitefs.showUser(0)" class="a brs">{lang invite_all_friend}</span>
					<span id="showUser_1" onclick="invitefs.showUser(1)">{lang selected}(<strong id="selectNum">0</strong>)</span>
					<span id="showUser_2" onclick="invitefs.showUser(2)">{lang unselected}(<cite id="unSelectTab">0</cite>)</span>
				</div>
			</div>
			<ul class="usl cl{if empty($_G['inajax'])} usl2{/if}" id="friends"></ul>
			<script type="text/javascript">
				var parameter = {'searchId':'username', 'showId':'friends', 'formId':'inviteform', 'showType':1, 'handleKey':'invitefs', 'maxSelectNumber':'20', 'selectTabId':'selectNum', 'unSelectTabId':'unSelectTab', 'maxSelectTabId':'remainNum'};
				var invitefs = new friendSelector(parameter);
				var clearlist = 0;
				<!--{if $inviteduids}-->
				invitefs.addFilterUser([$inviteduids]);
				<!--{/if}-->
				var listObj = $('friends');
				var page = 1;
				var gid = 0;
				var showNum = 0;
				var haveFriend = true;
				listObj.onscroll = function() {
					if(this.scrollTop >= this.scrollHeight/5) {
						page++;
						gid = isUndefined(gid) ? 0 : parseInt(gid);
						if(haveFriend) {
							getUser(page, gid);
						}
					}
				}
				function getUser(pageId, gid) {
					page = parseInt(pageId);
					gid = isUndefined(gid) ? 0 : parseInt(gid);
					var x = new Ajax();
					x.get('home.php?mod=spacecp&ac=friend&op=getinviteuser&inajax=1&page='+ page + '&gid=' + gid, function(s) {
						var data = eval('('+s+')');
						var singlenum = parseInt(data['singlenum']);
						var maxfriendnum = parseInt(data['maxfriendnum']);
						invitefs.addDataSource(data, clearlist);
						haveFriend = singlenum && singlenum == 20 ? true : false;
						if(singlenum && invitefs.allNumber < 20 && invitefs.allNumber < maxfriendnum && maxfriendnum > 20 && haveFriend) {
							page++;
							getUser(page);
						}
					});
				}
				getUser(page);
			</script>
			<form method="post" autocomplete="off" name="invite" id="inviteform" action="misc.php?mod=invite&amp;action=$_G[gp_action]&amp;id=$_G[gp_id]">
				<input type="hidden" name="formhash" value="{FORMHASH}" />
				<input type="hidden" name="referer" value="$_G['referer']" />
				<!--{if !empty($_G['inajax'])}--><input type="hidden" name="handlekey" value="$_G['gp_handlekey']" /><!--{/if}-->
				<p class="o pns{if empty($_G['inajax'])} mtw{/if}"><button type="submit" class="pn pnc" name="invitesubmit" value="yes"><strong>{lang invite_send}</strong></button></p>
			</form>
		</div>
<!--{if !$_G['inajax']}-->
	</div>
	<div class="sd">
		{subtemplate common/userabout}
	</div>
</div>
<!--{/if}-->
{template common/footer}